package cn.lazyturtle.bugpush.utils;



import cn.lazyturtle.bugpush.constant.CommonResponseEnum;
import cn.lazyturtle.bugpush.vo.ResponseEntity;

import static cn.lazyturtle.bugpush.constant.CommonResponseEnum.*;

/**
 * @author Administrator
 */
public class ResponseUtils {

    public static <T> ResponseEntity<T> body(String errCode, String errMsg, T t) {
        return new ResponseEntity<>(errCode, errMsg, t);
    }

    public static <T> ResponseEntity<T> body(CommonResponseEnum commonResponseEnum, T t) {
        return new ResponseEntity<>(commonResponseEnum.getCode(), commonResponseEnum.getMessage(), t);
    }


    public static ResponseEntity<?> success() {
        return new ResponseEntity<>(SUCCESS.getCode(), SUCCESS.getMessage(), true);
    }

    public static ResponseEntity<?> success(CommonResponseEnum commonResponseEnum) {
        return new ResponseEntity<>(commonResponseEnum.getCode(), commonResponseEnum.getMessage(), true);
    }

    public static <T> ResponseEntity<T> success(T data) {
        return new ResponseEntity<T>(SUCCESS.getCode(), SUCCESS.getMessage(), data);
    }

    public static ResponseEntity<?> fail() {
        return new ResponseEntity<>(FAIL.getCode(), FAIL.getMessage(), false);
    }

    public static ResponseEntity<?> fail(CommonResponseEnum commonResponseEnum) {
        return new ResponseEntity<>(commonResponseEnum.getCode(), commonResponseEnum.getMessage(), false);
    }

    public static ResponseEntity<?> fail(String message) {
        return new ResponseEntity<>(FAIL.getCode(), message, false);
    }

    public static ResponseEntity<?> noData() {
        return new ResponseEntity<>(NO_DATA.getCode(), NO_DATA.getMessage(), false);
    }

}
